ACTOR Blunderbuss : Weapon
{
	Weapon.SelectionOrder 2
	Weapon.AmmoUse1 5
	Weapon.KickBack 100
	Weapon.AmmoGive1 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Mana2"
	Weapon.AmmoType2 "Mana2"
	Weapon.AmmoUse2 6
	Inventory.PickupMessage "Blunderbuss" // "ETHEREAL CROSSBOW"
	Obituary "%o should know that %k's is not a licensed acupuncturist"
	AttackSound "weapons/blunderfire"
	Tag "Blunderbuss"
	+UNDROPPABLE
	Weapon.BobStyle InverseSmooth
	Weapon.BobSpeed 2.1
	Weapon.BobRangeY 0.4
	Weapon.BobRangeX 0.5
	States
	{
	Spawn:
		BLUN Z -1
		Stop
	Ready:
		BLUN B 0 A_JumpIfInventory("IsMarksman",1,"ReadyZoom")
		BLUN B 1 A_WeaponReady
		Loop
	ReadyZoom:
		BLUN B 1 A_WeaponReady(WRF_ALLOWZOOM)
		loop
	Deselect:
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel2")
		TNT1 A 0 A_TakeInventory("PowerZoomLevel1")
		BLUN B 1 A_Lower
		TNT1 B 0 A_Lower
		Loop
	Select:
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel2")
		TNT1 A 0 A_TakeInventory("PowerZoomLevel1")
		BLUN B 1 A_Raise
		TNT1 B 0 A_Raise
		Loop
	Fire:
		BLUN A 2 A_GiveInventory("MarksmanFocusCheck", 1)
		BLUN C 3 BRIGHT 
		BLUN D 0 BRIGHT A_GunFlash
		BLUN D 1 BRIGHT A_FireBullets(5.625,4.255, 7, 0, "BlunderbussPuff",FBF_USEAMMO|FBF_NORANDOM)
		BLUN D 1 BRIGHT A_SetPitch(Pitch-3)
		BLUN DEE 1 BRIGHT A_SetPitch(Pitch+1)
		BLUN FGHI 2
		TNT1 A 15
		BLUN JKLMNOP 2
		BLUN B 6 A_PlaySound("weapons/blunderload")
		Goto Ready
	AltFire:
		BLUN A 2 A_GiveInventory("MarksmanFocusCheck", 1)
		BLUN C 3 BRIGHT 
		BLUN D 0 Bright A_PlayWeaponSound ("weapons/blunderfire")
		BLUN D 0 BRIGHT A_GunFlash
		BLUN D 0 BRIGHT A_Recoil(4)
		BLUN D 1 BRIGHT A_FireCustomMissile("BlunderbussCannonball")//A_FireBullets(8.625,6.255, 7, (acs_executewithresult(516,7))+(acs_executewithresult(516,9)), "BlunderbussPuff")
		BLUN D 1 BRIGHT A_SetPitch(Pitch-3)
		BLUN DEE 1 BRIGHT A_SetPitch(Pitch+1)
		BLUN FGHI 2
		TNT1 A 15
		BLUN JKLMNOP 2
		BLUN B 6 A_PlaySound("weapons/blunderload")
		Goto Ready
	Zoom:
		TNT1 A 0 A_JumpIfInventory("PowerIsZoom",1,"ReadyZoom")
		TNT1 A 0 A_JumpIfInventory("PowerZoomLevel2",1,"UnZoom")
		TNT1 A 0 A_JumpIfInventory("PowerZoomLevel1",1,"Zoom2")
		TNT1 A 0 A_ZoomFactor(2.0)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel2",1)
		TNT1 A 0 A_GiveInventory("PowerZoomLevel1",1)
		TNT1 A 0 A_GiveInventory("PowerIsZoom",1)
		Goto Ready
	Zoom2:
		TNT1 A 0 A_ZoomFactor(4.0)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel1",1)
		TNT1 A 0 A_GiveInventory("PowerZoomLevel2",1)
		TNT1 A 0 A_GiveInventory("PowerIsZoom",1)
		Goto Ready
	UnZoom:
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_GiveInventory("PowerIsZoom",1)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel1",1)
		TNT1 A 0 A_TakeInventory("PowerZoomLevel2",1)
		Goto Ready
	}
}

Actor BlunderbussPuff
{
	+NOBLOCKMAP
	+NOGRAVITY
	+PUFFONACTORS
	+PUFFGETSOWNER
	+MTHRUSPECIES
	+FORCERADIUSDMG
	Radius 8
	Height 12
	Renderstyle Add
	Damagetype "Fire"
	Scale 0.5

	States
	{
	Spawn:
		CFCF QQ 0 Bright
		CFCF Q 0 Bright A_Explode(ACS_NamedExecuteWithResult("WOC Player Scale", FRandom(15,25), AGILITY, ABIL_RANGEDMASTERY, WOCTARGET), 48, 0, 0, 48)
		CFCF Q 1 Bright A_NoGravity
		CFCF Q 2 Bright //A_SpawnItemEx("BlunderbussPuffParticleFXSpawner")
		CFCF R 0 Bright A_Scream
		CFCF R 2 Bright //A_SpawnItemEx("BlunderbussPuffParticleFXSpawner")
		CFCF S 2 Bright //A_SpawnItemEx("BlunderbussPuffParticleFXSpawner")
		CFCF T 2 Bright
		CFCF U 2 Bright
		CFCF W 2 Bright
		CFCF X 2 Bright
		CFCF Z 2 Bright
		Stop
	}
}

actor BlunderbussPuffParticleFXSpawner
{
	+NoBlockMap +NoGravity +NoSector +NoInteraction +NoClip -Solid +CLIENTSIDEONLY
    states
	{
	Spawn:
	Active:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(Args[1], "Circle")
		TNT1 A 2
		TNT1 A 0 A_SpawnItemEx ("BlunderbussPuffParticleFX", frandom(-1, 1), frandom(-1, 1), frandom(-1, 1), (0.05)*frandom(-3, 3), (0.25)*frandom(-3, 3), (0.2)*frandom(-3, 3), 0 , SXF_ABSOLUTEMOMENTUM, Args[2])
		//TNT1 A 0 A_SpawnItemEx ("BlunderbussPuffParticleFX", frandom(-1, 1), frandom(-1, 1), frandom(-1, 1), (0.05)*frandom(-3, 3), (0.25)*frandom(-3, 3), (0.2)*frandom(-3, 3), 0 , SXF_ABSOLUTEMOMENTUM, Args[2]) 
		Stop
	Circle:
		TNT1 A 0
		TNT1 A 2 A_SpawnItemEx ("BlunderbussPuffParticleFX", frandom(-Args[0], Args[0]), 0, frandom(0, 8), (0.1)*frandom(1, 3), 0, (0.1)*frandom(1, 10), 0 , 129, Args[2]) 
		Loop
	Inactive:
		TNT1 A 1
		Loop
	}     
}

ACTOR BlunderbussPuffParticleFX
{
	+Missile
	+NoBlockmap
	+NoInteraction
	-Solid
	+CLIENTSIDEONLY
	Radius 0
	Height 0
	RenderStyle Add
	Alpha 0.8
	Scale 0.35
	//Gravity 0.125
	States
	{
	Spawn:
		CFCF QQRRSSTTUUVVWWXXZZ 1 Bright A_FadeOut(0.06)
		Stop
	}
}

ACTOR BlunderbussCannonball
{
	Radius 8
	Height 8
	Speed 35
	Damage (ACS_NamedExecuteWithResult("WOC Player Scale", FRandom(20,40), AGILITY, ABIL_RANGEDMASTERY, WOCTARGET))
	Projectile
	//BounceFactor 1.0
	+DOOMBOUNCE
	+THRUGHOST
	+WINDTHRUST
	+MTHRUSPECIES /*+NODAMAGETHRUST*/ +DONTBLAST
	-NOGRAVITY
	+DONTFALL
	+FORCERADIUSDMG
	Gravity 0.25
	Damagetype "Fire"
	BounceCount 3
	Scale 1.25
	Obituary "$OB_MPMACE"
	DeathSound "HunterBlunderbussCannonExplode"
	States
	{
	Spawn:
		FX02 CD 6
		Loop
	Death:
		TNT1 A 0 Radius_Quake (3, 10, 0, 2, 0)
		TNT1 A 0 Radius_Quake (2, 5, 0, 3, 0)
		FX02 F 0 Bright A_Explode(ACS_NamedExecuteWithResult("WOC Player Scale", 128, AGILITY, ABIL_RANGEDMASTERY, WOCTARGET), 128, 0)
		FX02 F 0 Bright A_ChangeFlag("NOGRAVITY", 1)
		FX02 F 4 Bright A_SetTranslucent(1,1)
		FX02 GHIJ 4 Bright
		Stop
	}
}